<?php namespace App\Admin\Goods\GsJmSchedule\Listeners;

use Input;
use DB;
use App\Core\Exceptions\InputError;
use App\Core\Service\Listeners\UpdateListener as Base;

class UpdateListener extends Base {

    public function onUpdateSaving(){
        $goods_id = Input::get('goods_id');
        $schedule_id = Input::get('schedule_id');
        $id = Input::get('id');

        if(!$goods_id || !$schedule_id){
            throw new InputError('参数有误');
            return;
        }

        $goods = DB::table('goods_schedule_jimiao')
            ->where('schedule_id','=',$schedule_id)
            ->where('goods_id','=',$goods_id)
            ->where('is_delete','=','0')
            ->first();
        if($goods && $id != $goods->id ){
            throw new InputError('商品已存在');
            return;
        }

    }


}

